<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

        // 两两相比较，谁前一位比后一位大进行交换。
        var aim = [2, 4, 23, 64, 13, 124, 32, 42, 32, 45, 6, 8];
        // 需要执行的趟数
        for (var j = 0; j < aim.length; j++) {
            // 比较次数
            for (var i = 0; i < aim.length - j; i++) {
                if (aim[i] > aim[i+1]) {
                    var temp = aim[i];
                    aim[i] = aim[i+1];
                    aim[i+1] = temp;
                }
            }
        }
        alert(aim)
    </script>
</head>
<body>
    
</body>
</html>